import { postAction } from "@/command/netTool";
import { useDetailReactive } from "@/hooks/detail";
import { watch } from "vue";
import * as vant from "vant";
const { showFailToast, showLoadingToast, closeToast } = vant;

export const useRequest = () => {
  // 获取当前用户个人信息
  const [personInfo] = useDetailReactive(
    "api/H5/gov/perCenter/personCenterMsg",
    {
      avatar: "",
      sex: "0",
      address: "",
      id: "123456",
      smFlag: "已实名",
      phone: "",
      name: "",
    }
  );
  watch(personInfo, (value) => {
    postAction("/api/H5/gov/perCenter/savePersonCenterMsg", value).catch(() => {
      showFailToast("修改失败");
    });
  });
  return {
    personInfo,
  };
};
